#include "expression.h"

Expression::Expression(const string& str) : Constante(EXPRESSION){
    this->type = EXPRESSION;
        int pos =0;
        string tmp(str);
        pos = tmp.find("'");
    while(pos != string::npos){
        tmp.replace(pos,sizeof(char)," ");
        pos = tmp.find("'");
    }
    this->str = tmp;
}

Constante* Expression::operator+(const Constante& c)const{
    return new Expression(c.toExp()+str+" +");
}

Constante* Expression::operator*(const Constante& c)const{
    return new Expression(c.toExp()+str+" *");
}

Constante* Expression::operator-(const Constante& c)const{
    return new Expression(c.toExp()+str+" -");
}

Constante* Expression::operator/(const Constante& c)const{
    return new Expression(c.toExp()+str+" /");
}

std::string Expression::print()const{
    return "'"+str+"'";
}

Constante* Expression::operator-()const{
    return new Expression(str+" SIGN");
}
